<script>
	import store from '@/store';
	import config from '@/common/config.js'
	
	export default {
		// 此处globalData为了演示其作用，不是uView框架的一部分
		globalData: {
			applyIndex: 0,
			baseURL: config.baseURL,
			fileURL: config.fileURL,
			fileUploadURL: config.fileUploadURL
		},
		onLaunch() {
			// 1.1.0版本之前关于http拦截器代码，已平滑移动到/common/http.interceptor.js中
			// 注意，需要在/main.js中实例化Vue之后引入如下(详见文档说明)：
			// import httpInterceptor from '@/common/http.interceptor.js'
			// Vue.use(httpInterceptor, app)
			// process.env.VUE_APP_PLATFORM 为通过js判断平台名称的方法，结果分别如下：
			/**
			 * h5，app-plus(nvue下也为app-plus)，mp-weixin，mp-alipay......
			 */
			
			if(uni.getStorageSync('lifeData')){
				let lifeData = uni.getStorageSync('lifeData')
				this.$u.vuex('Authorization', lifeData.Authorization)
				this.$u.vuex('userdetail', lifeData.userdetail)
				this.$u.vuex('userType', lifeData.userType)
				this.$u.vuex('storeId', lifeData.storeId)
				this.$u.vuex('enterpriseId', lifeData.enterpriseId)
				// this.$u.vuex('operatorid', lifeData.operatorid)
				this.$u.vuex('franchiseId', lifeData.franchiseId)
				this.$u.vuex('storeOnline', lifeData.storeOnline)
			}else{

			}
			
			store.dispatch('getWebSetting')
			store.dispatch('getDetails')
			store.dispatch('signalrConnection');
		},
		onShow() {
			// store.dispatch('getDetails')
		},
		onHide() {
			
		},
		onError(error) {
			uni.$tracker.trackError({
				message: error.message,
				raw: JSON.stringify(error)
			}, { 
				type: 'UNI_APP_ERROR',
				platform: uni.getSystemInfoSync().platform 
			})
			
			console.log('捕捉全局错误error',error)
		}
	}
</script>

<style lang="scss">
	/* #ifndef APP-NVUE */
	@import "uview-ui/index.scss";
	@import "static/css/common.scss";
	@import "static/font/iconfont.css";
	/* #endif */
</style>